package com.yogurt.statistics.controller;


import com.baomidou.mybatisplus.extension.api.R;
import com.yogurt.statistics.service.DailyService;
import com.yogurt.statistics.vo.EchartsVO;
import com.yogurt.utils.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author yogurt
 * @since 2022-09-21
 */
@RestController
@RequestMapping("/statistics/daily")
@CrossOrigin
public class DailyController {

    @Autowired
    private DailyService dailyService;

    @ApiOperation("统计某一天的注册人数")
    @PostMapping("/registerNum/{day}")
    public Result registerNum(@PathVariable String day) {
        dailyService.registerNum(day);
        return Result.ok();
    }

    @ApiOperation("图表显示(统计数据)")
    @PostMapping("/getShowData")
    public Result getShowData(@RequestBody EchartsVO vo) {
        Map<String, Object> map = dailyService.getShowData(vo);
        return Result.ok().data(map);
    }

}

